package com.sskj.wallet.http;


import com.lzy.okgo.OkGo;
import com.lzy.okgo.request.GetRequest;
import com.lzy.okgo.request.PostRequest;
import com.sskj.common.adapter.slimadapter.IViewInjector;
import com.sskj.common.base.HttpData;
import com.sskj.lib.bean.BorrowMoneyRecordBean;
import com.sskj.lib.bean.CurrentTypeBean;
import com.sskj.lib.bean.PageBean;
import com.sskj.lib.bean.ShiftBean;
import com.sskj.lib.http.HttpConfig;
import com.sskj.wallet.bean.AddressAllBean;
import com.sskj.wallet.bean.BillAssetBean;
import com.sskj.wallet.bean.BillMsgBean;
import com.sskj.wallet.bean.ChongTiRecordBean;
import com.sskj.wallet.bean.ChongtiDetailsBean;
import com.sskj.wallet.bean.CoinListBean;
import com.sskj.wallet.bean.RechargeBean;
import com.sskj.wallet.bean.StateTransferBean;
import com.sskj.wallet.bean.TransferListBean;
import com.sskj.wallet.bean.WalletDetailBean;
import com.sskj.wallet.bean.WithdrawMsgBean;
import com.sskj.wallet.ui.activity.ChongtiDetailsActivity;

import java.util.List;

/**
 * 作者 :吕志豪
 * 简书：https://www.jianshu.com/u/6e525b929aac
 * github：https://github.com/lvzhihao100
 * 描述：
 * 创建时间：2018-10-15 14:08
 */
public class HttpService {


    /**
     * 钱包资产信息
     *
     * @param walletType
     * @return
     */
    public PostRequest<HttpData<WalletDetailBean>> getWalletDetail(int walletType) {
        return OkGo.<HttpData<WalletDetailBean>>post(HttpConfig.BASE_URL + HttpConfig.WALLET_DATAIL)
                .params("type", walletType);
    }

    /**
     * 划转
     *
     * @param coinType
     * @param amount
     * @param transferTo
     * @param transferFrom
     * @return
     */
    public PostRequest<HttpData> toTransfer(String coinType, String amount, String transferTo, String transferFrom) {
        return OkGo.<HttpData>post(HttpConfig.BASE_URL + HttpConfig.TRANSFER)
                .params("type", coinType)
                .params("price", amount)
                .params("wallet_to", transferFrom)
                .params("wallet_for", transferTo);
    }

    /**
     * 划转列表
     *
     * @param page
     * @param size
     * @return
     */
    public PostRequest<HttpData<PageBean<TransferListBean>>> getTransferRecord(int page, int size, String walletType) {
        return OkGo.<HttpData<PageBean<TransferListBean>>>post(HttpConfig.BASE_URL + HttpConfig.TRANSFER_RECORD)
//                .params("page", page)
                .params("page", page)
                .params("size", size);
    }

    /**
     * 充/提 币种列表
     *
     * @return
     */
    public PostRequest<HttpData<List<CoinListBean>>> getCoinLists(int type) {
        return OkGo.<HttpData<List<CoinListBean>>>post(HttpConfig.BASE_URL + HttpConfig.COIN_LIST)
                .params("type", type);
    }

    /**
     * 币充值页面
     *
     * @param coin
     * @return
     */
    public GetRequest<HttpData<RechargeBean>> getRechargeData(String coin) {
        return OkGo.<HttpData<RechargeBean>>get(HttpConfig.BASE_URL + HttpConfig.RECHARGE)
                .params("wall_type", coin);
    }

    /**
     * 提币地址添加删除
     *
     * @param address 钱包地址
     * @param act     操作类型，删除 del, 添加不用这个参数
     * @param note    备注
     * @param type    1btc 2eth 3ltc 4aicash 5usdt
     * @return
     */
    public PostRequest<HttpData> addAddress(String address, String act, String note, String type) {
        return OkGo.<HttpData>post(HttpConfig.BASE_URL + HttpConfig.ADD_WITHDRAW_ADDRESS)
                .params("address", address)
                .params("act", act)
                .params("notes", note)
                .params("type", type);
    }

    public PostRequest<HttpData<AddressAllBean>> getAddressList() {
        return OkGo.post(HttpConfig.BASE_URL + HttpConfig.ADDRESS_LIST);
    }

    /**
     * 充值/提币 记录
     *
     * @param pid
     * @param type
     * @param page
     * @param size
     * @return
     */
    public PostRequest<HttpData<PageBean<ChongTiRecordBean>>> getRecorde(String pid, String type, int page, int size) {
        return OkGo.<HttpData<PageBean<ChongTiRecordBean>>>post(HttpConfig.BASE_URL + HttpConfig.CHONG_TI_RECORD)
                .params("pid", pid)
                .params("type", type)
                .params("page", page)
                .params("size", size);
    }

    /**
     * 提币页面数据
     *
     * @param pid
     * @return
     */
    public GetRequest<HttpData<WithdrawMsgBean>> getWithdrawMsg(String pid) {
        return OkGo.<HttpData<WithdrawMsgBean>>get(HttpConfig.BASE_URL + HttpConfig.WITHDRAW_MSG)
                .params("pid", pid);
    }

    /**
     * 提币申请
     *
     * @param amount  数量
     * @param pid     币id
     * @param address 地址
     * @return
     */
    public PostRequest<HttpData> withDraw(String amount, String pid, String address) {
        return OkGo.<HttpData>post(HttpConfig.BASE_URL + HttpConfig.WITH_DRAW)
                .params("num", amount)
                .params("pid", pid)
                .params("address", address);
    }

    /**
     * 账单明细
     *
     * @param walletType 钱包id
     * @param coinType   币种类型btc eth ltc aicash usdt
     * @param page
     * @param size
     * @return
     */
    public PostRequest<HttpData<PageBean<BillAssetBean>>> getBillAssets(int walletType, String coinType, int page, int size) {
        return OkGo.<HttpData<PageBean<BillAssetBean>>>post(HttpConfig.BASE_URL + HttpConfig.BILL_ASSET)
                .params("page", page)
                .params("size", size)
                .params("id", walletType)
                .params("type", coinType);
    }

    /**
     * 账单详情
     *
     * @param billId 账单ID
     * @return
     */
    public PostRequest<HttpData<BillMsgBean>> getBillId(String billId) {
        return OkGo.<HttpData<BillMsgBean>>post(HttpConfig.BASE_URL + HttpConfig.BILL_MSG)
                .params("id", billId);
    }

    /**
     * 充 提币 详情
     *
     * @param recordId
     * @param recordType
     * @return
     */
    public GetRequest<HttpData<ChongtiDetailsBean>> getChongtiDetails(String recordId, String recordType) {
        return OkGo.<HttpData<ChongtiDetailsBean>>get(HttpConfig.BASE_URL + HttpConfig.RECORD_DETAIL)
                .params("id", recordId)
                .params("type", recordType);
    }

    /**
     * 活期宝货币类型
     *
     * @return
     */
    public PostRequest<HttpData<List<String>>> getCoins() {
        return OkGo.<HttpData<List<String>>>post(HttpConfig.BASE_URL + HttpConfig.CURRENT_TYPE);
    }

    public PostRequest<HttpData<ShiftBean>> getCoinUsable(String coinName, String type) {
        return OkGo.<HttpData<ShiftBean>>post(HttpConfig.BASE_URL + HttpConfig.FUNCTIONS_SHIFT_BALANCE)
                .params("type", coinName)
                .params("ptype", type);
    }

    /**
     * 用户之间转账
     *
     * @param coin         币种
     * @param mobile       转账对方手机号
     * @param amount       转账数量
     * @param fiveMd5Value 资金密码
     * @return
     */
    public PostRequest<HttpData> stateTransfer(String coin, String mobile, String amount, String fiveMd5Value) {
        return OkGo.<HttpData>post(HttpConfig.BASE_URL + HttpConfig.STATE_TRANSFER)
                .params("type", coin)
                .params("phone", mobile)
                .params("price", amount)
                .params("pwd", fiveMd5Value);
    }

    /**
     * 用户之间账户划转记录
     *
     * @param page
     * @param size
     * @return
     */
    public PostRequest<HttpData<PageBean<StateTransferBean>>> getStateTransferRecord(int page, int size) {
        return OkGo.<HttpData<PageBean<StateTransferBean>>>post(HttpConfig.BASE_URL + HttpConfig.STATE_TRANSFER_RECORD)
                .params("page", page)
                .params("size", size);
    }
}